<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title> new document </title>
  <meta name="generator" content="editplus" />
  <meta name="author" content="" />
  <meta name="keywords" content="" />
  <meta name="description" content="" />
	<script type="text/javascript" src="jquery-1.6.1.js"></script>
	<script type="text/javascript">
		
		$(function(){

			//创建两个span元素，其中一个用id标识，创建后过滤出具有id属性的span为其添加click事件，然后退回（过滤前），将其
			//添加到表格中具有name属性，且后代子节点中包含a元素的tr的第一个td子元素中
			$("<span id='f'>fffff</span><span>xxxxxx</span>").filter("#f").click(function(){
				alert("fff");
			}).end().appendTo("tr[name]:has(a) > td:first");
			
		});
	</script>  

	<style type="text/css">
		table{
			width:500px;
			border:solid 1px #cccccc;
			border-collapse:collapse;
		}

		table tr{
			height:30px;
		}

		table tr td{
			border:solid 1px #cccccc;
		}
	</style>


 </head>

 <body>
	<div id="ttt"></div>
	<table>
		<tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td><a href="#"></a></td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
		<tr name="2">
			<td>&nbsp;</td>
			<td><a href="#"></a></td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
	</table>
 </body>
</html>
